package dao;

import dataBean.ScoresDo;
import dataBean.UserInfoDo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by lxl on 2015/10/25.
 */
public interface ScoresDao {

    @Insert("insert into scores(course_id,user_id,score_id)values(#{courseID},#{userID},#{scoreID})")
    public int insertScores( ScoresDo scoresDo ) ;

    @Select("select score_id from scores where course_id=#{courseID} and user_id=#{userID}")
    public int selectScoresByKey( ScoresDo scoresDo ) ;

    @Select("select score_id from scores where course_id=#{courseID} and user_id=#{userID}")
    public int selectScoresByUsername( ScoresDo scoresDo ) ;

    @Select("select id from scores where user_id = ( select id from user_info where username =#{username})")
    public List<Integer> selectScoreIdByUsername( String username ) ;

    @Select("select * from user_info where id in ( select user_id from scores where course_id = #{id} )")
    public List<UserInfoDo> selectUserInfoByCourseId(int id) ;

    @Update("update scores set score_id=#{scoreID} where course_id=#{courseID} and user_id=#{userID}")
    public int updateScoresByScoreId(ScoresDo scoresDo) ;

}
